package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

/**
 * 客户跟进历史
 */
@Setter
@Getter
public class CustomerTraceHistory {
    private Long id;
    //跟进时间
    // @DateTimeFormat 把前端传过来的日期字符串自动按照pattern规定的格式解析成date类型的对象
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;
    //跟进内容
    private String traceDetails;
    //跟进方式
    private SystemDictionaryItem traceType;
    //跟进结果
    private Integer traceResult;
    //客户
    private Customer customer;
    //录入人
    private Employee inputUser;
    //录入时间
    private Date inputTime;

    public String getJson(){
        HashMap map = new HashMap();
        map.put("id",id);
        map.put("traceTime",traceTime);
        map.put("traceResult",traceResult);
        map.put("inputTime",inputTime);
        map.put("traceDetails",traceDetails);
        if(traceType!=null){
            map.put("traceTypeId",traceType.getId());
        }
        if(customer!=null){
            map.put("customerId",customer.getId());
        }
        if(inputUser!=null){
            map.put("inputUserId",inputUser.getId());
        }
        return JSON.toJSONString(map);
    }
    //跟进类型
}